		function getchapter() {
			$("#chapterid").empty();
			var cid = $("#courseid").val();
			$
					.ajax({
						type : "GET",
						url : "/schoolsystem/getExampPaperChapter/" + cid,
						dataType : "json"
					})
					.done(
							function(data) {
								$("#chapterid").append($("<option value='0'>"+"请选择"+ "</option>"))
								for ( var i in data) {
									$("#chapterid").append($("<option value='"+ data[i].specialty_id +"'>"
															+ data[i].specialty_name
															+ "</option>"))
								}
							});
		}
		function getPoints() {
			$("#pointsid").empty();
			var cid = $("#chapterid").val();
			$.ajax({
			url : "/schoolsystem/getExampPaperPoints/" + cid,
			dataType : "json"}).done(
				function(index) {
					$('#myModal').modal('show');
					for ( var i in index) {
						Index(index[i].specialty_id,index[i].specialty_name);
					}
			})

		}
		$.ajax({
				type : "GET",
				url : "/schoolsystem/getExampPaperCourse",
				dataType : "json"
		}).done(function(data) {
				for ( var i in data) {
					$("#courseid").append(
						$("<option value = '"+data[i].specialty_id+"'>"
								+ data[i].specialty_name
								+ "</option>"))
				}
		});
		$("#courseid").change(function() {
			getchapter();
		})
		$("#chapterid").change(function() {
		    $("tbody tr").remove();
			getPoints();
		})
		var a;
		function numChange(index){
			$.ajax({
				type : "GET",
				url : "getSpecialty?specialty_id="+index.id+"&number="+index.value,
				success: function(data) {
				    if(a == index.id){
						$("#"+index.id+"+span").remove();
					}
				    a = index.id;
					if(data >= 0){
						$("tbody+p").remove();
						$("#"+index.id+"+span").remove();
					}else if(data == -1){
						$("#"+index.id).after($("<span style='color:red;'>知识点没有这么多题目</span>"));
					}else if(data == -2){
						$("#"+index.id).after($("<span style='color:red;'>输入数量不能为负数</span>"));
					}
				},
				error: function(data) {
					alert("提交失败");
				}
			});
		}
		function Index(index,name){
			$.ajax({
				type : "GET",
				url : "getSpecialty?specialty_id="+index,
				success: function(data) {
					if(data>-1){
						$("#cha").append(
								$("<tr><td>"+
								index+"</td><td>"+
								name+
								"</td><td><div class='col-sm-5'>"+
								"<input class='form-control' id='"+index+"' name='num"+index+"' type='number' min='0' onchange='numChange(this)' " +
										"class='form-control match-rotation-input' οnkeyup='value=value.replace(/[^\d]/g,'')' οnblur='value=value.replace(/[^\d]/g,'')' ng-model='schedule.round' placeholder='请输入数字'/>"
								+"</div></td><td>"+data+"</td></tr>"));
					}
				},
				error: function(data) {
					alert("提交失败");
				}
			});
		}
		
		function saveKnowledge(){
			var params = $("#mytbody").serializeArray();  
	         var values = {};  
	         for( x in params ){  
	            values[params[x].name] = params[x].value;  
	         }
             if("" == $("input+span").text()){
            	 $.ajax({
            		 type : "GET",
            		 url : "getSpecialtySubmit",
            		 data : {idata : JSON.stringify(values)},
            		 dataType : "json",
            		 success: function(data) {
            			 $("tbody+p").remove();
            			 if(data.falg){
            				 $("#subjectNum").val(data.countSubject);
            				 $("#examPaperScore").val(data.countFraction);
            				 $('#myModal').modal('hide');
            			 }else{
            				 $("tbody+p").remove();
            				 $("#cha").after($("<p style='color:red;'>题目不能超过50道题</p>"))
            			 }
            		 }
            	 });
             }
		}
		